﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PiaoanWeb.AppLogic.BusinessLogicLayer;
using PiaoanWeb.AppLogic.DataAccessLayer;
using PiaoanWeb.Helpers;
namespace PiaoanWeb
{
    public partial class ProductList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CategoriesBLL categoryBLL = new CategoriesBLL();
                categoryDDL.DataSource = categoryBLL.GetAllCategoriesExcludeDeleted();
                categoryDDL.DataBind();

                ProductsBLL productsBLL = new ProductsBLL();
                ProductRepeater.DataSource = productsBLL.GetProductsByCategoryID(Convert.ToInt32(categoryDDL.SelectedValue));
                ProductRepeater.DataBind();
            }
        }

        protected void categoryDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductsBLL productsBLL = new ProductsBLL();
            ProductRepeater.DataSource = productsBLL.GetProductsByCategoryID(Convert.ToInt32(categoryDDL.SelectedValue));
            ProductRepeater.DataBind();
        }
    }
}